<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     * 商品
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('category_id')->comment('分类ID');
            $table->string('name')->comment('商品名称');
            $table->string('subtitle')->comment('商品副标题');
            $table->string('main_image')->nullable()->comment('主图');
            $table->text('carousel_image')->nullable()->comment('轮播图');
            $table->string('product_sn')->comment('商品编号');
            $table->decimal('price', 10, 2)->comment('商品价格');
            $table->decimal('market_price', 10, 2)->comment('市场价');
            $table->decimal('cost_price', 10, 2)->comment('成本价');
            $table->integer('stock')->default(0)->comment('库存');
            $table->integer('sold_num')->default(0)->comment('销量');
            $table->decimal('integral_multiple', 6, 2)->default(1)->comment('积分倍率');
            $table->decimal('direct_push', 10, 2)->default(0)->comment('直推分润');
            $table->decimal('equal_push', 10, 2)->default(0)->comment('平级分润');
            $table->decimal('weight', 10, 2)->default(0)->comment('商品重量');
            $table->text('description')->nullable()->comment('商品描述');
            $table->longText('detail')->nullable()->comment('商品详情');
            $table->tinyInteger('status')->default(1)->comment('状态(0:下架 1:上架 2:预售)');
            $table->tinyInteger('is_hot')->default(1)->comment('是否热销');
            $table->tinyInteger('is_new')->default(1)->comment('是否新品');
            $table->tinyInteger('is_recommend')->default(1)->comment('是否推荐');
            $table->integer('sort')->default(0)->comment('排序');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `products` comment '产品表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
